package cn.mumzone.pos.presenter;

import android.util.Log;

import com.alibaba.fastjson.JSONObject;

import java.util.ArrayList;
import java.util.List;

import cn.mumzone.basic.mvp.AbsPresenter;
import cn.mumzone.basic.net.http.callback.ApiCallBack;
import cn.mumzone.basic.net.response.BaseResponse;
import cn.mumzone.basic.net.response.PageListResponse;
import cn.mumzone.basic.util.BigDecimalUtil;
import cn.mumzone.basic.util.StringUtils;
import cn.mumzone.pos.model.BillDetailEntity;
import cn.mumzone.pos.model.OffWorkEntity;
import cn.mumzone.pos.model.OffWorkTicketEntity;
import cn.mumzone.pos.model.SettleItemEntity;
import cn.mumzone.pos.model.source.BillsRepository;
import cn.mumzone.pos.model.source.UserRepository;
import cn.mumzone.pos.presenter.contract.OffWorkRecordContract;
import cn.mumzone.pos.util.BillUtil;

/**
 * Created By Dlx
 * on 2019/7/12
 */
public class OffWorkRecordPresenter extends AbsPresenter<OffWorkRecordContract.View, UserRepository> implements OffWorkRecordContract.Presenter {


    @Override
    public void loadOffWorkRecord(String startTime, String endTime, String key, String pageNum) {
        mView.showLoadingDialog();
        ApiCallBack<PageListResponse<OffWorkEntity>> callBack = new ApiCallBack<PageListResponse<OffWorkEntity>>() {
            @Override
            public void onSuccess(PageListResponse<OffWorkEntity> response) {
                mView.dismissLoadingDialog();
                mView.showOffWorkRecord(response);
            }

            @Override
            public void onError(BaseResponse response) {
                mView.dismissLoadingDialog();
                mView.showError(response.getMsg());

            }
        };
        mRepo.getOffWorkRecord(startTime, endTime, key, pageNum, callBack);
        addSubscrebe(callBack);
    }

    @Override
    public void loadShiftDetail(String id) {
        mView.showLoadingDialog();
        ApiCallBack<OffWorkTicketEntity> callBack = new ApiCallBack<OffWorkTicketEntity>() {
            @Override
            public void onSuccess(OffWorkTicketEntity entity) {
                mView.dismissLoadingDialog();
                mView.doPrintShiftTicket(entity);
            }

            @Override
            public void onError(BaseResponse response) {
                mView.dismissLoadingDialog();
            }
        };
        mRepo.getShiftRecordDetail(id, callBack);
        addSubscrebe(callBack);

    }



}
